package com.ebao.action.user;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.ebao.action.base.BaseAction;
import com.ebao.constants.UserType;
import com.ebao.constants.WebConstants;
import com.ebao.po.user.TFollow;
import com.ebao.po.user.TUser;
import com.ebao.service.user.IFollowService;

/**
 * @author snow
 * @Date 2012-9-10
 */
public class FollowAction extends BaseAction {

	private static final long serialVersionUID = 1094481677633471411L;
	
	@Resource
	private IFollowService followService;
	
	private String id;
	
	/**
	 * 用户查询自己关注的医生列表
	 */
	@Action(value = "follow-list", results = {@Result(name = SUCCESS, location = "follow.jsp")})
	public String followList(){
		TUser user = (TUser) session.get(WebConstants.LOGIN_USER);
		log.info("session user:" + user);
		String jpql = "from TFollow where ownType=? and own=? and followerType=?";
		List<TFollow> doctorList = followService.getListByJpql(jpql, 
				UserType.COMMON_USER,user.getId(),UserType.DOCTOR);
		
		request.put("doctorList", doctorList);
		
		return SUCCESS;
	}

	/**
	 * 用户查询被关注列表
	 */
	@Action(value = "followed-list", results = {@Result(name = SUCCESS, location = "follow.jsp")})
	public String followedList(){
		TUser user = (TUser) session.get(WebConstants.LOGIN_USER);
		
		
		
		return SUCCESS;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
}
